package com.hqd.ch03.v51.factory.support;

import com.hqd.ch03.v51.beans.factory.config.DependencyDescriptor;
import com.hqd.ch03.v51.factory.config.BeanDefinitionHolder;
import com.hqd.ch03.v51.utils.BeanUtils;

public interface AutowireCandidateResolver {

    default boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
        return bdHolder.getBeanDefinition().isAutowireCandidate();
    }

    default boolean isRequired(DependencyDescriptor descriptor) {
        return descriptor.isRequired();
    }

    default boolean hasQualifier(DependencyDescriptor descriptor) {
        return false;
    }


    default Object getSuggestedValue(DependencyDescriptor descriptor) {
        return null;
    }

    default Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, String beanName) {
        return null;
    }

    default AutowireCandidateResolver cloneIfNecessary() {
        return BeanUtils.instantiateClass(getClass());
    }

}
